from mongoengine import *
import datetime


class Members(DynamicDocument):
    # id = IntField(primary_key=True)
    name = StringField(max_length=100, db_field='name', required=True)
    email = EmailField(max_length=200, unique=True, required=False)
    SEX_CHOICE = (
        (True, '男'),
        (False, '女')
    )
    sex = BooleanField(choices=SEX_CHOICE, default=True)
    ctime = DateTimeField(db_field='createTime', default=datetime.datetime.now)
    # 索引
    # meta = {
    #     'indexes': [
    #         'title',  # single-field index
    #         '$title',  # text index
    #         '#title',  # hashed index
    #         ('title', '-rating'),  # compound index
    #         ('category', '_cls'),  # compound index
    #         {
    #             'fields': ['created'],
    #             'expireAfterSeconds': 3600  # ttl index
    #         }
    #     ]
    # }
